package data.generator;

import java.util.ArrayList;
import java.util.Random;

import model.CD;

public class CDGenerator {

	private static String[] artists = { "Britney Spears", "Jennifer Lopez", "Shakira", "Lady Gaga" };
	private static String[] titles = { "Nevermind", "Don't know why I'm still singing", "We will rock you", "Pokerface" };
	
	/* Make sure the class can't be instantiated */
	private CDGenerator() {
	}
	
	public static ArrayList<CD> generateCDs(int amount) {
	
		// Create list of books
		ArrayList<CD> books = new ArrayList<CD>();
		
		// Fill list
		for (int i = 0; i < amount; i++) {
			CD cd = generateCD();
			books.add(cd);
		}
		
		// Return list
		return books;
	}
	
	public static CD generateCD() {
		
		String artist;
		String title;
		
		Random random = new Random();
		
		// Create a random author
		artist = artists[random.nextInt(artists.length)];
		
		// Create a random title
		title = titles[random.nextInt(titles.length)];
		
		// Create new book
		CD cd = new CD();
		
		// Set book properties
		cd.setArtist(artist);
		cd.setTitle(title);
		
		// Return result
		return cd;
	}
}